//
//  ZTHeaderViewNoAddress.m
//  FD
//
//  Created by xiaofang wang on 2019/1/12.
//  Copyright © 2019年 ZhiYuan Network. All rights reserved.
//  没有选择地址的时候的表头

#import "ZTHeaderViewNoAddress.h"
#define k15 15
#define k40  40
#define k5 5
#define kWhiteColor [UIColor whiteColor]

//总h: 40 + (40*3 + 2) +5+5+ 40 = 202 + 10 = 212
@interface ZTHeaderViewNoAddress()
/**div0 自提门店*/
@property (nonatomic, strong) UIView *div0;
/**自提门店lb*/
@property (nonatomic, strong) UILabel *ziTiMenDianLb;



/**div1*/
@property (nonatomic, strong) UIView *div1;
/**div10*/
@property (nonatomic, strong) UIView *div10;
/**联系人信息*/
@property (nonatomic, strong) UILabel *contactMsgLb;

/**姓名*/
@property (nonatomic, strong) UILabel *nameLb;
/**div11*/
@property (nonatomic, strong) UIView *div11;
/**联系方式*/
@property (nonatomic, strong) UILabel *phoneLb;
/**div12*/
@property (nonatomic, strong) UIView *div12;

/**数组view装入数组中一次性布局*/
@property (nonatomic, strong) NSMutableArray *div1ViewArr;


/**div2*/
@property (nonatomic, strong) UIView *div2;
/**餐品信息*/
@property (nonatomic, strong) UILabel *canpinMsgLb;
/**线*/
@property (nonatomic, strong) UIView *lightGrayLineView;


@end

@implementation ZTHeaderViewNoAddress
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
        
        self.backgroundColor = kMainLightGrayColor; //灰色线
    }
    return self;
}

- (void)setupUI {
    
    [self addSubview:self.div0];
    [self addSubview:self.div1];
    [self addSubview:self.div2];
    
    [self.div0 addSubview:self.ziTiMenDianLb];
    
    
    [self.div1 addSubview:self.div10];
    [self.div1 addSubview:self.div11];
    [self.div1 addSubview:self.div12];
    [self.div10 addSubview:self.contactMsgLb];
    [self.div11 addSubview:self.nameLb];
    [self.div12 addSubview:self.phoneLb];
    [self.div1ViewArr addObject:self.div10];
    [self.div1ViewArr addObject:self.div11];
    [self.div1ViewArr addObject:self.div12];

    
    [self.div2 addSubview:self.canpinMsgLb];
    [self.div2 addSubview:self.lightGrayLineView];
}

#pragma mark - layout
- (void)layoutSubviews {
    [super layoutSubviews];

    [self layoutDiv0];
    [self layoutDiv1];
    [self layoutDiv2];
}


- (void)layoutDiv0 {
    [self.div0 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self);
        make.height.mas_equalTo(k40);
    }];
    
    [self.ziTiMenDianLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div0.mas_left).offset(k15);
        make.top.bottom.right.equalTo(self.div0);
    }];
    
}


- (void)layoutDiv1 {
    [self.div1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self.div0.mas_bottom).offset(k5);
        make.height.mas_equalTo(k40*3 + 2); //k40 * 3 + 2(两条线)
    }];
    
    [self.div1ViewArr mas_distributeViewsAlongAxis:(MASAxisTypeVertical) withFixedSpacing:1 leadSpacing:0 tailSpacing:0];
    [self.div1ViewArr mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div1.mas_left);
        make.right.equalTo(self.div1.mas_right);
    }];
    
    [self.contactMsgLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div10.mas_left).offset(k15);
        make.top.right.bottom.equalTo(self.div10);
    }];
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div11.mas_left).offset(k15);
        make.top.right.bottom.equalTo(self.div11);
    }];
    [self.phoneLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div12.mas_left).offset(k15);
        make.top.right.bottom.equalTo(self.div12);
    }];
}

- (void)layoutDiv2 {
    [self.div2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self.div1.mas_bottom).offset(k5);
        make.height.mas_equalTo(k40);
    }];
    [self.canpinMsgLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div2.mas_left).offset(k15);
        make.top.right.bottom.equalTo(self.div2).offset(2);
    }];
    [self.lightGrayLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div2.mas_left).offset(k15);
        make.right.equalTo(self.div2.mas_right).offset(-k15);
        make.height.mas_equalTo(1);
        make.bottom.equalTo(self.div2.mas_bottom);
    }];
}


#pragma mark - getter
- (UIView *)div0 {
    if (!_div0) {
        _div0 = [UIView new];
        _div0.backgroundColor = kWhiteColor;//[UIColor redColor];//
    }
    return _div0;
}
- (UILabel *)ziTiMenDianLb {
    if (!_ziTiMenDianLb) {
        _ziTiMenDianLb = [[UILabel alloc] init];
        _ziTiMenDianLb.text = NSLocalizedString(CollectionShop, @"自提门店");
    }
    return _ziTiMenDianLb;
}





//!!!!:div1
- (UIView *)div1 {
    if (!_div1) {
        _div1 = [UIView new];
        _div1.backgroundColor = kMainLightGrayColor; //[UIColor greenColor]; //kWhiteColor;
    }
    return _div1;
}
//开空间
- (NSMutableArray *)div1ViewArr {
    if (!_div1ViewArr) {
        _div1ViewArr = [NSMutableArray array];
    }
    return _div1ViewArr;
}

- (UIView *)div10 {
    if (!_div10) {
        _div10 = [UIView new];
        _div10.backgroundColor = kWhiteColor;
    }
    return _div10;
}
- (UILabel *)contactMsgLb {
    if (!_contactMsgLb) {
        _contactMsgLb = [[UILabel alloc] init];
        _contactMsgLb.text = NSLocalizedString(Home_contacts, @"联系人");
    }
    return _contactMsgLb;
}
- (UIView *)div11 {
    if (!_div11) {
        _div11 = [UIView new];
        _div11.backgroundColor = kWhiteColor;
    }
    return _div11;
}
- (UILabel *)nameLb {
    if (!_nameLb) {
        _nameLb = [UILabel new];
        _nameLb.text = NSLocalizedString(Name, @"姓名");
    }
    return _nameLb;
}
- (UIView *)div12 {
    if (!_div12) {
        _div12 = [UIView new];
        _div12.backgroundColor = kWhiteColor;
    }
    return _div12;
}

- (UILabel *)phoneLb {
    if (!_phoneLb) {
        _phoneLb = [UILabel new];
        _phoneLb.text = NSLocalizedString(LianXiFangShi, @"联系方式");
    }
    return _phoneLb;
}



//!!!!:div2
- (UIView *)div2 {
    if (!_div2) {
        _div2 = [UIView new];
        _div2.backgroundColor = kWhiteColor; //[UIColor yellowColor];
    }
    return _div2;
}
- (UILabel *)canpinMsgLb {
    if (!_canpinMsgLb) {
        _canpinMsgLb = [UILabel new];
        _canpinMsgLb.text = NSLocalizedString(Home_CanPinMsg, @"餐品信息");
    }
    return _canpinMsgLb;
}
- (UIView *)lightGrayLineView {
    if (!_lightGrayLineView) {
        _lightGrayLineView = [UIView new];
        _lightGrayLineView.backgroundColor = kMainLightGrayColor;
    }
    return _lightGrayLineView;
}

#pragma mark - ffdfad
@end
